1 00:00:00,520 --> 00:00:06,340 Let's go ahead and add a leaderboard to our game so we could see our stats and the stats of the other 2 00:00:06,340 --> 00:00:07,610 people who are playing. 3 00:00:07,630 --> 00:00:13,420 I'm going to do a leaderboard with three metrics I'm going to do kills deaths and points. 4 00:00:13,420 --> 00:00:13,730 Right. 5 00:00:13,780 --> 00:00:17,170 And the kills, I think I'll make it player versus player kills. 6 00:00:17,170 --> 00:00:21,170 Not for NPCs, but you could easily modify that if you want. 7 00:00:21,190 --> 00:00:28,960 Let's go to server script service, hit the plus, add a script and then I'm going to call this game 8 00:00:28,960 --> 00:00:32,110 manager and sometimes I call it leaderboard. 9 00:00:32,110 --> 00:00:36,990 It depends on how much I want to put in there, but I want to put saving the leaderboard too. 10 00:00:37,000 --> 00:00:39,010 So that's what I'm going to call game manager. 11 00:00:39,010 --> 00:00:41,860 I'm going to have more than just the leaderboard script in here. 12 00:00:43,530 --> 00:00:46,200 Go ahead and delete that print statement right there. 13 00:00:46,200 --> 00:00:51,520 And then we're going to add a function that adds a leaderboard to players as they enter the game. 14 00:00:51,540 --> 00:00:55,410 So we'll say local function add board. 15 00:00:55,410 --> 00:00:55,800 Right. 16 00:00:55,830 --> 00:00:57,750 And a player is going to get passed in. 17 00:00:57,750 --> 00:00:59,610 That's the player we're adding our board to. 18 00:00:59,640 --> 00:01:01,710 All players are going to get a leaderboard. 19 00:01:02,580 --> 00:01:09,030 Let's say local board equals instance Dot No. 20 00:01:09,180 --> 00:01:16,080 We're going to make a new instance of a folder, a folder or a model you could do a model to and the 21 00:01:16,080 --> 00:01:17,730 player is going to be the parent. 22 00:01:17,730 --> 00:01:23,880 So the second argument is, the parent of what we're creating instance new is creating a new instance 23 00:01:23,880 --> 00:01:26,510 of a new instance of a folder. 24 00:01:26,520 --> 00:01:33,810 So board name must be equal to leader stats. 25 00:01:33,810 --> 00:01:35,670 This has to be spelled right. 26 00:01:35,670 --> 00:01:37,500 You have to have a lowercase l. 27 00:01:37,530 --> 00:01:40,170 There can't be any variation or it's not going to work. 28 00:01:40,170 --> 00:01:42,090 You won't get an error, it just won't work. 29 00:01:42,630 --> 00:01:46,260 And then now we're going to put metrics on our leaderboard. 30 00:01:46,260 --> 00:01:54,630 We're going to do points right instance new, and we're going to make a new instance of an int value. 31 00:01:54,630 --> 00:01:55,800 INT value is for it. 32 00:01:55,800 --> 00:01:56,820 Integer value. 33 00:01:56,820 --> 00:01:58,620 One, two, three, four. 34 00:01:58,620 --> 00:01:59,010 Right. 35 00:01:59,010 --> 00:02:04,740 So we're not going to have decimal points, we're only going to have integer points and the parent is 36 00:02:04,740 --> 00:02:05,820 going to be the board. 37 00:02:05,820 --> 00:02:12,300 So we're putting the points on the board, we're putting the board on the player. 38 00:02:13,140 --> 00:02:13,530 All right. 39 00:02:13,530 --> 00:02:17,190 So now let's get our points, get a name for that. 40 00:02:17,190 --> 00:02:18,840 Let's call that points. 41 00:02:18,840 --> 00:02:22,830 This is what's going to be displayed in the header of the leaderboard in the game. 42 00:02:22,830 --> 00:02:25,440 So spell it the way you want people to see it. 43 00:02:25,590 --> 00:02:36,030 Now we'll do another metric for kills instance, new int value, and then board is going to be the parent. 44 00:02:36,600 --> 00:02:48,330 Let's go ahead and do kills dot name equals kills and we want deaths to write local deaths equal instance, 45 00:02:48,330 --> 00:02:53,760 new int value board and deaths. 46 00:02:53,760 --> 00:02:59,430 We're going to give that a name dot name deaths. 47 00:02:59,760 --> 00:03:00,570 Cool. 48 00:03:00,570 --> 00:03:03,660 So we have kills deaths and points all in the board. 49 00:03:03,660 --> 00:03:10,890 The board is on the player and the player is going to get this board added when we use this game dot 50 00:03:10,890 --> 00:03:15,990 players services player added event. 51 00:03:15,990 --> 00:03:19,350 Then we're going to connect that to our add board. 52 00:03:19,350 --> 00:03:24,690 Get rid of those two extra parentheses when we captured an event and connect it to a function. 53 00:03:24,690 --> 00:03:28,080 We're just going to use the name, not the, not the parentheses. 54 00:03:28,080 --> 00:03:33,780 So the player added is going to know to pass a player in when you connect that function. 55 00:03:33,780 --> 00:03:34,980 Pretty cool. 56 00:03:34,980 --> 00:03:36,300 Let's go ahead and try it. 57 00:03:36,300 --> 00:03:41,730 Every player that enters the game is going to get this because every time you enter the game, the player 58 00:03:41,730 --> 00:03:44,910 added function is is fired. 59 00:03:44,910 --> 00:03:48,900 Look at that points kills deaths. 60 00:03:48,900 --> 00:03:50,630 We have a leaderboard. 61 00:03:50,640 --> 00:03:55,020 Let's go ahead and in the next video we'll work on points. 62 00:03:55,020 --> 00:03:56,610 Start populating that.